<%@ page
	import="com.tilab.wsig.WSIGConfiguration,com.tilab.wsig.soap.SoapClient,vnu.edu.news.helpper.SOAPRequestMaker"
	language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="utf-8"%>

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>.: WSIG Console :.</title>
<link rel="stylesheet" href="wsig.css" />
</head>
<body>
	<div class="nav" align="right">
		<font size="-2"><a href="http://jade.tilab.com/" target="_top">Jade
				- Java Agent DEvelopment Framework</a></font>
	</div>
	<CENTER>
		<h1>.: Customize Your News Services :.</h1>
	</CENTER>
	<h3>
		<a href="index.jsp" class="title">Home</a> - <a
			href="NewsServices.jsp" class="title">News Services</a>
	</h3>
	<%
		// Get configuration
		WSIGConfiguration wsigConfig = (WSIGConfiguration) application
				.getAttribute("WSIGConfiguration");

		// Get parameters
		String SOAPUrl = request.getParameter("soapurl");
		if (SOAPUrl == null) {
			SOAPUrl = wsigConfig.getWsigUri();
		}

		String userName = request.getParameter("userName");
		if (userName == null) {
			userName = "";
		}

		String sportPriority = request.getParameter("sportPriority");
		if (sportPriority == null) {
			sportPriority = "5";
		}

		String technologyPriority = request
				.getParameter("technologyPriority");
		if (technologyPriority == null) {
			technologyPriority = "5";
		}
		String SOAPRequest = SOAPRequestMaker.makeSOAPRequest(userName,
				Integer.parseInt(technologyPriority),
				Integer.parseInt(sportPriority));//request.getParameter("soaprequest");
		if (SOAPRequest == null) {
			SOAPRequest = "";
		}
		String SOAPResponse = "";
		if (SOAPRequest != null && !"".equals(SOAPRequest)
				&& userName.length() > 0) {
			SOAPResponse = SoapClient.sendStringMessage(SOAPUrl,
					SOAPRequest);
		}
	%>

	<CENTER>
		<form method="post" action="NewsServices.jsp">
			<table width="40%" border="1">
				<tr>
					<td colspan="4" class="head" align="center"><h2>User's
							Informations</h2></td>
				</tr>
				<tr>
					<td width="25%" class="title" style="width: 100px;">WebService
						url:</td>
					<td width="75%" colspan="3" class="value"><input type="text"
						name="soapurl" size="50" value="<%out.print(SOAPUrl);%>"></input></td>
				</tr>

				<tr>
					<td width="25%" class="title">Your name:</td>
					<td width="75%" colspan="3" class="value"><input type="text"
						name="userName" size="50" value="<%out.print(userName);%>"></input></td>
				</tr>

				<tr>
					<td width="35%" class="title">Sport's priority:</td>
					<td width="15%" class="value"><input type="text"
						name="sportPriority" size="5"
						value="<%out.print(sportPriority);%>"></input></td>
					<td width="35%" class="title">Technology's priority:</td>
					<td width="15%" class="value"><input type="text"
						name="technologyPriority" size="5"
						value="<%out.print(technologyPriority);%>"></input></td>
				</tr>

				<%-- Hidden comment 
				<tr>
					<td width="30%" class="title">SOAP request:</td>
					<td colspan="3" class="value"><textarea cols=70 rows=10
							WRAP="physical" name="soaprequest">
						<%
							out.print(SOAPRequest);
						%>
					</textarea></td>
				</tr>
				--%>
				<tr>
					<td width="25%" class="title">SOAP response:</td>
					<td width="75%" colspan="3" class="value"><textarea
							readonly="readonly" cols=50 rows=10 WRAP="physical"
							name="soapresponse">
							<%
								out.print(SOAPResponse);
							%>
						</textarea></td>
				</tr>
				<tr>
					<td class="value" colspan="4" align="center"><input
						type="submit" value="Send"></input>
						<button type="reset">Reset</button></td>
				</tr>
			</table>
		</form>
	</CENTER>
	<h3>
		<a href="index.jsp" class="title">Home</a> - <a
			href="NewsServices.jsp" class="title">News Services</a>
	</h3>
</body>
</html>